<template>
  <div class="container">
    <router-link :to="{name: 'DoTest', params: { id: test.id }}" target="_blank">
      <div class="test-topic">
        <a class="common-a">
          <div class="go-test">去测试</div>
          <el-image class="img" :src="test.cover" />
        </a>
        <div class="title">{{ test.name }}</div>
        <div class="title_number">共{{ test.itemIds.split(',').length }}道心理测试题</div>
      </div>
    </router-link>
  </div>
</template>

<script>
import Swal from 'sweetalert2'
import { delTestPaper } from '@/api/test'
export default {
  props: {
    test: Object()
  },
  data() {
    return {

    }
  },
  methods: {
    delTestPaper(id) {
      Swal.fire({
        title: '确定要删除该测试问卷吗？',
        icon: 'question',
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        showCancelButton: true,
        heightAuto: false
      }).then(res => {
        if (res.isConfirmed) {
          delTestPaper({ testId: id }).then(res => {
            if (res.code === 1) {
              Swal.fire({
                title: '删除成功',
                icon: 'success',
                confirmButtonText: 'OK',
                heightAuto: false
              })
              this.$emit('findTestList')
            }
          })
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.container{
    width: 250px;
    height: 250px;
    display: inline-block;
    background: #fff;
    // box-shadow: 0 2px 20px 0 #eaeaea;
    border-radius: 10px;
    position: relative;
    padding-right: 20px;
  .title{
    text-align: left;
    font-size: 16px;
    color: #333;
    line-height: 20px;
    margin: 20px 20px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    height: 20px;
  }
  .title_number{
    text-align: left;
    font-size: 13px;
    color: grey;
    line-height: 20px;
    margin: 5px 20px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
.test-topic{
    width: 230px;
    height: 250px;
    display: inline-block;
    background: #fff;
    box-shadow: 0 2px 20px 0 #eaeaea;
    border-radius: 10px;
    position: relative;
}
.go-test{
    position: absolute;
    left: 50%;
    top: 50%;
    width: 70px;
    height: 36px;
    line-height: 36px;
    background: rgba(0,0,0,.5);
    border-radius: 8px;
    font-family: PingFangSC-Medium;
    font-size: 14px;
    color: #fff;
    -webkit-transform: translate(-50%,-50%);
    -ms-transform: translate(-50%,-50%);
    transform: translate(-50%,-50%);
    text-align: center;
    z-index: 1;
}
.img {
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    height: 153px;
}
.test-topic:hover {
  .common-a{
    filter:alpha(Opacity=80);
    -moz-opacity:0.8;
    opacity: 0.8;
    text-decoration: none;
  }
  .go-test{
    filter:alpha(opacity=30);
    -moz-opacity:0.3;
    opacity:0.3;
  }
}
.title_number{
  font-size: 14px;
  padding-top: 5px;
  color: #1a7777;
}
.btns {
  padding-top: 20px;
  display: inline-block;
  .el-button{
    margin-left: 10px;
  }
}
</style>
